import axios from "axios";
import { ClientStorage } from '../../packages/index'

var instance = axios.create({

})

instance.interceptors.request.use(
  (config) => {
    //post请求头
    //config.headers.post["Content-Type"] = "application/x-www-form-urlencoded;charset=UTF-8";

    // 跨域请求携带Cookie信息
    config.withCredentials = true


    return config;

  },
  error => {

    return Promise.reject(error);
  }
);

instance.interceptors.response.use(
  response => {

    if (response.status == 200) {
      return Promise.resolve(response.data);
    } else {
      return Promise.reject(response.data);
    }
  },
  async ({ error, response }) => {

    return Promise.reject(error)
  }
);

export default instance;// axios;